<template>
    <view class="w-340 h-auto mt-20 fl-co-cen ju-bet bg-ffffff rd-10 overflow-hidden" @click="on_click">
        <image class="w-100% h-340" :src="JSON.parse(props.goodsItem.goodsDto.imagesUrl)[0]" mode="aspectFill"></image>
        <view class="w-100% h-auto fl-co ju-bet p-10">
            <text class="fs-28 font-bold">{{ props.goodsItem.goodsDto.name }}</text>
            <view class="text-red">
                <text class="fs-26">¥</text>
                <text class="fs-36">{{ props.goodsItem.price }}</text>
            </view>
        </view>
    </view>
</template>

<script setup>
    const props = defineProps({
        goodsItem: {
            type: Object,
            default() {
                return {
                    id: null,
                    imagesUrl: '',
                    name: '',
                    price: null
                };
            }
        }
    });

    const emit = defineEmits(['handle_click']); //定义点击事件的名字
    const on_click = () => {
        //发射点击事件
        emit('handle_click', `点击了${props.goodsItem.name}`);
    };
</script>

<style></style>
